package com.google.code.b0rx0r.program;

import java.io.Serializable;


public abstract class SnapPoint implements Serializable, Comparable<SnapPoint> {

	private static final long serialVersionUID = "SnapPoint 1.1".hashCode(); //$NON-NLS-1$

	protected String name;

	public abstract int getOffset();
	public abstract void setOffset(int offset);

	protected Sequencable sample;

	public SnapPoint(Sequencable sample, String name) {
		this.sample = sample;
		this.name = name;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Override
	public int hashCode() {
		final int offset = getOffset();
		final int prime = 31;
		int result = 1;
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		result = prime * result + offset;
		result = prime * result + ((sample == null) ? 0 : sample.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		final int offset = getOffset();
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		final SnapPoint other = (SnapPoint) obj;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		if (offset != other.getOffset())
			return false;
		if (sample == null) {
			if (other.sample != null)
				return false;
		} else if (!sample.equals(other.sample))
			return false;
		return true;
	}

	@Override
	public int compareTo(SnapPoint o) {
		return getOffset() - o.getOffset();
	}

}